<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
	<div id="dialog-message">
 <table class="table table-striped table-hover table-bordered">
					  <thead>
						<tr id="sys_user_table_title">
						  <th  width="20">编号</th>
						  <th  width="20" fname="userNameCheckBox"><input id="userNameCheckBox" type="checkbox"></th>
						  <th  width="60" fname="userName">登陆名称</th> 
						  <th  width="60" fname="userShowName">显示名称</th>
						  <th  width="60" fname="userEngListName">英文名称</th>
						  <th  width="40" fname="age">年龄</th> 
						  <th  width="70" fname="tell">电话</th> 
						  <th  width="100" fname="showTime">创建时间</th> 
						</tr>
					  </thead>
					  <tbody id="sys_user_table">
						 
					  </tbody>
					</table> 
					<ul class="pagination" id="user_pagination">
					  
					</ul> 	
					</div>
<script>
(function(){
	//改变他的启用禁用的状态
	function changeUserState(){
		var allstate =$("div[name='sys_user_table_state_tr_td']");
		for(var i=0;i<allstate.length;i++){
			var bc = $(allstate[i]);
			if(bc.text()==1){
				bc.html('<font color="green">启用</font>');
			}else if(bc.text()==0){
				bc.html('<font color="red">禁用</font>');
			}
		}
		$("#sys_user_table").children().click(function(){
			if($(this).find("[name=sys_user_table_checkbox]")[0].checked==true){
				$(this).find("[name=sys_user_table_checkbox]")[0].checked=false;
			}else{
				$(this).find("[name=sys_user_table_checkbox]")[0].checked=true;
			}
		});
	};
	//改变头像 和性别，还有类型
	function changeUserImage(){ 
		var allstate =$("div[name='sys_user_table_userImage_tr_td']");
		for(var i=0;i<allstate.length;i++){
			var bc = $(allstate[i]);
			bc.html('<img src="'+bc.text()+'" width="25" height="25"/>');
		}
		var allstate =$("div[name='sys_user_table_sex_tr_td']");
		for(var i=0;i<allstate.length;i++){
			var bc = $(allstate[i]);
			if(bc.text()==1){
				bc.html('<font color="green">男</font>');
			}else if(bc.text()==0){
				bc.html('<font color="red">女</font>');
			}
		}
		var allstate =$("div[name='sys_user_table_userType_tr_td']");
		for(var i=0;i<allstate.length;i++){
			var bc = $(allstate[i]);
			if(bc.text()==4){
				bc.html('<font color="green">助教</font>');
			}else if(bc.text()==6){
				bc.html('<font color="red">管理员</font>');
			}
		}
	}
	//全选中事件
	$("#userNameCheckBox").click(function(){
		var allc =$("[name=sys_user_table_checkbox]");
		for(var i=0;i<allc.length;i++){
			$(allc[i])[0].checked=$(this)[0].checked;
		}
			 
	});
	//用户搜索
	function loadUser(event,data){
		if(typeof(data)=="undefined"){
			data={};
		}
		var url ="${pageContext.request.contextPath}/edu/sysUserAction.do?method=get25User";
		 
		data.userName="${param.userName}";
		data.tell="${param.userName}";
		data.userShowName="${param.userName}";
		data.userEngListName="${param.userName}";
		var cp =$("#user_pagination").find(".active");
		data.start=1;
		if(cp.length>0){
			var ccp=$(cp[0]).text();
			if(parseInt(ccp)){
				data.start=ccp;
			}
		}  
		$("#table_user").wgrid({
					table_title:"sys_user_table_title",
					tbodyId:"sys_user_table",
					pagination:"user_pagination",
					url:url,
					checkbox:true,
					data:data,
					success:function(){
						changeUserState();
						//changeUserImage();
					}
		});
	};
	$(function(){
		loadUser(null,{});
	})
})();
</script>